package com.example.bankend.util;

import com.aliyun.dysmsapi20170525.*;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.*;
import com.aliyun.tea.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
/**
 * @author luolinila
 * @date 2025/6/17 15:09
 */
public class Sample {
    public static void sendSms(String phone, String captcha) throws Exception {
        Config config = new Config()
                //这里修改为我们上面生成自己的AccessKey ID
                .setAccessKeyId("LTAI5tPYLSfdJCJ4HakG97va")
                //这里修改为我们上面生成自己的AccessKey Secret
                .setAccessKeySecret("HGjBzzpBjht3PZXqHwsHOJVbixEn4U");
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        Client client = new Client(config);
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
            //短信签名
            .setSignName("阿里云短信测试")
            //短信模板
            .setTemplateCode("SMS_154950909")
            //这里填写接受短信的手机号码
            .setPhoneNumbers(phone)
            //验证码
            .setTemplateParam("{\"code\":\"" + captcha + "\"}");
        // 复制代码运行请自行打印 API 的返回值
        client.sendSms(sendSmsRequest);
    }
}
